﻿namespace Realm.Web.Json
{
    public static class JsonHelper
    {/*
        #region Standard Models

        public static JObject GetJObject(StudyParameter studyParameter)
        {
            return new JObject
            {
                {"Id", studyParameter.Id},
                {"Name", studyParameter.Name},
                {"SortOrderId", studyParameter.SortOrderId},
                {"Parameter", GetJObject(studyParameter.Parameter)},
                {"InputConfigurations", GetJArray(studyParameter.ParameterInputConfigurations)},
            };
        }

        public static JObject GetJObject(ParameterInputType parameterType)
        {
            return new JObject
            {
                {"Id", parameterType.Id},
                {"Name", parameterType.Name}
            };
        }

        public static JObject GetJObject(Parameter parameter)
        {
            return new JObject
            {
                {"Id", parameter.Id},
                {"Name", parameter.Name},
                {"AuditTypeId", parameter.AuditTypeId},
                {"InputType", GetJObject(parameter.InputType)},
                {"ParameterType", parameter.ParameterType}
            };
        }

        public static JObject GetJObject(Role role)
        {
            return new JObject
            {
                {"Id", role.Id},
                {"Name", role.Name},
                {"DisplayName", role.DisplayName},
                {"Description", role.Description}
            };
        }

        public static JObject GetJObject(Section section)
        {
            return new JObject
            {
                {"Id", section.Id},
                {"Name", section.Name},
                {"StudyId", section.StudyId},
                {"AuditTypeId", section.AuditTypeId},
                {"SortOrderId", section.SortOrderId},
                {"IsActive", section.IsActive},
                {"SectionType", section.SectionType},
                {"StudyParameters", GetJArray(section.StudyParameters)}
            };
        }

        public static JObject GetJObject(Study study)
        {
            return new JObject
            {
                {"Id", study.Id},
                {"Sponsor", study.Sponsor},
                {"Protocol", study.Protocol},
                {"IsActive", study.IsActive},
                {"AuditTypeId", study.AuditTypeId}
            };
        }

        public static JObject GetJObject(User user)
        {
            return new JObject
            {
                {"Id", user.Id},
                {"Name", user.Name},
                {"AuditTypeId", user.AuditTypeId},
                {"Roles", GetJArray(user.Roles)},
            };
        }

        public static JObject GetJObject(AuditReason auditReason)
        {
            return new JObject
            {
                {"Id", auditReason.Id},
                {"Title", auditReason.Title},
                {"Description", auditReason.Description}
            };
        }

        public static JObject GetJObject(AuditType auditType)
        {
            return new JObject
            {
                {"Id", auditType.Id},
                {"EntityName", auditType.EntityName},
                {"Reasons", GetJArray(auditType.Reasons)}
            };
        }

        public static JObject GetJObject(StudyParameterInputConfiguration studyParameterInputConfiguration)
        {
            return new JObject
            {
                {"Id", studyParameterInputConfiguration.Id},
                {"Feature", studyParameterInputConfiguration.ParameterInputTypeFeature.Name},
                {"Value", studyParameterInputConfiguration.Value}
            };
        }
        #endregion

        #region Helper Models

        public static JObject GetJObject(User user, bool debugMode)
        {
            var userJObject = GetJObject(user);
            return new JObject
            {
                {"User", userJObject},
                {"DebugMode", debugMode}
            };
        }

        #endregion

        #region JArrays

        public static JArray GetJArray(IEnumerable<StudyParameter> parameters)
        {
            var jArray = new JArray();
            parameters.ForEach(x => jArray.Add(GetJObject(x)));
            return jArray;
        }

        public static JArray GetJArray(IEnumerable<Parameter> parameters)
        {
            var jArray = new JArray();
            parameters.ForEach(x => jArray.Add(GetJObject(x)));
            return jArray;
        }

        public static JArray GetJArray(IEnumerable<Role> roles)
        {
            var jArray = new JArray();
            roles.ForEach(x => jArray.Add(GetJObject(x)));
            return jArray;
        }

        public static JArray GetJArray(IEnumerable<Section> sections)
        {
            var jArray = new JArray();
            sections.ForEach(x => jArray.Add(GetJObject(x)));
            return jArray;
        }

        public static JArray GetJArray(IEnumerable<Study> studies)
        {
            var jArray = new JArray();
            studies.ForEach(x => jArray.Add(GetJObject(x)));
            return jArray;
        }

        public static JArray GetJArray(IEnumerable<AuditReason> auditReasons)
        {
            var jArray = new JArray();
            auditReasons.ForEach(x => jArray.Add(GetJObject(x)));
            return jArray;
        }

        public static JArray GetJArray(IEnumerable<User> users)
        {
            var jArray = new JArray();
            users.ForEach(x => jArray.Add(GetJObject(x)));
            return jArray;
        }

        public static JArray GetJArray(IEnumerable<AuditType> auditTypes)
        {
            var jArray = new JArray();
            auditTypes.ForEach(x => jArray.Add(GetJObject(x)));
            return jArray;
        }

        public static JArray GetJArray(IEnumerable<ParameterInputType> parameterTypes)
        {
            var jArray = new JArray();
            parameterTypes.ForEach(x => jArray.Add(GetJObject(x)));
            return jArray;
        }

        public static JArray GetJArray(IEnumerable<StudyParameterInputConfiguration> studyParameterInputConfigurations)
        {
            var jArray = new JArray();
            studyParameterInputConfigurations.ForEach(x => jArray.Add(GetJObject(x)));
            return jArray;
        }
        #endregion
*/
    }
}